﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Nova.dataDataSetTableAdapters;

namespace Nova
{
    /// <summary>
    /// Interaction logic for AddGroup.xaml
    /// </summary>
    public partial class AddGroup : Window
    {
        public AddGroup()
        {
            InitializeComponent();
            textBox1.Focus();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            dataDataSet dataset = new dataDataSet();
            string groupName = textBox1.Text;
            dataset.Groups.AddGroupsRow(groupName);
            GroupsTableAdapter da = new GroupsTableAdapter();
            da.Update(dataset);
            this.DialogResult = true;
            this.Close();
        }

        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                button1_Click(this, e);
            }
            if (e.Key == Key.Escape)
            {
                this.Close();
            }

        }
    }
}
